home *** CD-ROM | disk | FTP | other *** search
- property sprPrimeiro -- Primeiro dos 12 sprites que compoe universo
- property memPrimeiro -- Primeiro membro
- property velMaxima -- Velocidade em pixels/s
- property puloMaximo -- Pulo maximo em pixels
- property areaX, areaY -- Tamanho da area de sensibilidade nos cantos
-
- property intMemPrimeiro -- Numero do primeiro membro
- property ultimoX, ultimoY -- Para verificar se precisa atualizar posicao
- property bScrolling -- Se esta scrollando
- property cronoScrolling -- Cronometro do controle de scroll
- property numIcones, sprIcones, posIcones, sprOutros
- property memoria, limitado
-
- on getBehaviorDescription
- return "Controle dos sprites do universo"
- end
-
- on getPropertyDescriptionList
- set p_list = [ ¬
- #sprPrimeiro: [ #comment: "Primeiro dos 12 sprites que compoe"¬
- & " universo", ¬
- #format: #integer, ¬
- #default: 1 ],¬
- #memPrimeiro: [ #comment: "Primeiro membro do universo dividido"¬
- & " em 10 pedacos", ¬
- #format: #string, ¬
- #default: "Universo1" ], ¬
- #velMaxima: [ #comment: "Velocidade maxima (pixels/s)",¬
- #format: #integer, ¬
- #default: 5 ],¬
- #puloMaximo: [ #comment: "Pulo maximo (pixels)",¬
- #format: #integer, ¬
- #default: 40 ],¬
- #areaX: [ #comment: "Tamanho da area sensivel de scroll nas bordas",¬
- #format: #integer, ¬
- #default: 80 ],¬
- #areaY: [ #comment: "Tamanho da area sensivel de scroll nas bordas",¬
- #format: #integer, ¬
- #default: 40 ],¬
- #numIcones: [ #comment: "Numero de Icones",¬
- #format: #integer, ¬
- #default: 7 ],¬
- #sprIcones: [ #comment: "Primeiro sprite dos icones",¬
- #format: #integer, ¬
- #default: 24 ],¬
- #memoria: [ #comment: "Limite de memoria para scrollar",¬
- #format: #integer, ¬
- #default: 0 ]¬
- ]
- return p_list
- end
-
- on beginSprite me
- put the number of member memPrimeiro into intMemPrimeiro
- set sprOutros = 22
- -- Acerta icones
- set posIcones = espalha(numIcones,1440,960)
- -- Posiciona sprites
- posiciona me, 0, 0
- put 0 into ultimoX
- -- Levanta cortina
- repeat with i = sprPrimeiro to sprPrimeiro + 19
- set the visible of sprite i to true
- end repeat
- -- Scrolling
- put false into bScrolling
-
- global myMemSize
- if myMemSize <= memoria * 1024 * 1024 then
- set limitado = true
- else
- set limitado = false
- end if
-
- -- Atualiza
- updateStage
- end
-
- on cleanSprite me
- global gPronde
- if gPronde <> 1 then
- repeat with i = sprPrimeiro to sprPrimeiro + 19
- puppetSprite i,false
- end repeat
- end if
- end
-
- on clicaIcone me, num
- sendSprite 120, #comecaAnima
- updateStage
- cursor 4
- vaiPagina num, true
- cursor -1
- end
-
- on vaiIcone me, num
- set ultimoX = 320 - the locH of getAt(posIcones,num)
- set ultimoY = 240 - the locV of getAt(posIcones,num)
- posiciona me, ultimoX, ultimoY
- end
-
- on posiciona me, x, y
- -- Icones
- repeat with i = 1 to numIcones
- set ix = the locH of getAt(posIcones,i)
- set ix = (ix + x) mod 1440
- if ix < 0 then set ix = ix + 1440
- if ix > 900 then set ix = ix - 1440
- set iy = the locV of getAt(posIcones,i)
- set iy = (iy + y) mod 960
- if iy < 0 then set iy = iy + 960
- if i < 7 or the frame < marker("UniUltra") then
- set the loc of sprite (sprIcones + i - 1) to point(ix,iy)
- set the loc of sprite (sprOutros + i - 1) to point(ix,iy)
- end if
- -- if i = 4 then put " -- > (" & y & ") " & iy & " =? " & the locV of sprite (sprIcones + i - 1)
- end repeat
-
- -- Normaliza X
- put x mod 1440 into x
- if x < 0 then put x + 1440 into x
- -- Normaliza Y
- put y mod 480 into y
- if y < 0 then put y + 480 into y
- put y - 480 into y
- put sprPrimeiro into spr
- repeat with i_y = 1 to 2
- put x into pos_x
- put (pos_x + 71) / 72 into tmp
- put pos_x - 72 * tmp into pos_x
- put 20 - tmp into mem
- repeat with i_x = 1 to 10
- puppetSprite spr, true
- put mem mod 20 into mem
- set the memberNum of sprite spr to mem + intMemPrimeiro
- put mem+1 into mem
- set the loc of sprite spr to point(pos_x+36,y+240)
- put spr+1 into spr
- put 72+pos_x into pos_x
- end repeat
- put 480 + y into y
- end repeat
-
-
- end
-
- on idleSprite me
- if limitado then return
-
- global gMustUpdate, gCritico
- if rollOver(the spriteNum of me) and gCritico = 0 then
- -- Captura mouse
- put the mouseH into x
- put the mouseV into y
- -- Pega raios
- put abs(x - 320) - 320 + areaX into rx
- if rx > areaX then put areaX into rx
- put abs(y - 240) - 180 + areaY into ry
- if ry > areaY then put areaY into ry
- -- Calcula velocidades
- -- put "rx=" & rx & ", ry=" & ry
- if rx > 0 then
- put rx * velMaxima / areaX into velX
- else
- put 0 into velX
- end if
- if ry > 0 then
- put ry * velMaxima / areaY into velY
- else
- put 0 into velY
- end if
- -- put "velX=" & velX & ", velY=" & velY
- -- Calcula quantidades de scroll
- if velX > 0 or velY > 0 then
- if bScrolling then
- put the timer into agora
- put (agora - cronoScrolling) into passou
- put velX * passou / 100 into dx
- if velX > 0 and dx = 0 then put 1 into dx
- put velY * passou / 100 into dy
- if velY > 0 and dy = 0 then put 1 into dy
- put dx * dx + dy * dy into dtotal
- put puloMaximo * puloMaximo into dtmp
- if dtotal > dtmp then
- put sqrt(dtotal) into dtotal
- put dx * puloMaximo / dtotal into dx
- put dy * puloMaximo / dtotal into dy
- end if
- if x < 320 then
- put ultimoX - dx into ultimoX
- else
- put ultimoX + dx into ultimoX
- end if
- if y < 240 then
- put ultimoY - dy into ultimoY
- else
- put ultimoY + dy into ultimoY
- end if
- posiciona me, ultimoX, ultimoY
- set gMustUpdate = true
- put agora into cronoScrolling
- else
- put the timer into cronoScrolling
- put true into bScrolling
- end if
- else
- -- Se fora da area de sensivel
- put false into bScrolling
- end if
- else
- -- Se nem sobre imagem esta
- put false into bScrolling
- end if
- end
-
-
-
-